package com.adamfass.tractorbeam;

import java.util.ArrayList;
import java.util.HashSet;

public class GameObjectManager {
  private final HashSet<PhysicsGameObject> targettableObjects =
    new HashSet<PhysicsGameObject>();
  
  private final HashSet<GameEntity> gameEntities = 
    new HashSet<GameEntity>();
   
  // for update in main game loop
  public Iterable<GameEntity> getGameEntities() {
    return new ArrayList<GameEntity>(gameEntities);
  }
  
  // for targetting
  public Iterable<PhysicsGameObject> getTargettableObjects() {
    return new ArrayList<PhysicsGameObject>(targettableObjects);
  }
  
  // for adding tractor beams
  public void addNonTargettableGameEntity(GameEntity entity) {
    gameEntities.add(entity);
  }
  
  // for removing tractor beams
  public void removeNonTargettableGameEntity(GameEntity entity) {
    gameEntities.remove(entity);
    entity.cleanUp();
  }
  
  // for adding saucers and balls
  public void addTargettableObject(PhysicsGameObject object) {
    gameEntities.add(object);
    targettableObjects.add(object);
  }
  
  // for removing balls
  public void removeTargettableObject(PhysicsGameObject object) {
    removeNonTargettableGameEntity(object);
    targettableObjects.remove(object);
  }
}
